#include "predicates.h"
#include "segment_iterator.h"
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

void make_bounds(segment segm, std::vector<std::pair<int, int> >& old_bounds, int leftmost)
{
    auto it = segment_iterator(segm.first, segm.second);

    for (; it != segment_iterator(segm.second); ++it)
    {
        old_bounds[it->x - leftmost].first = std::min(old_bounds[it->x - leftmost].first, static_cast<int>(it->y));
        old_bounds[it->x - leftmost].second = std::max(old_bounds[it->x - leftmost].second, static_cast<int>(it->y));
    }

    old_bounds[it->x - leftmost].first = std::min(old_bounds[it->x - leftmost].first, static_cast<int>(it->y));
    old_bounds[it->x - leftmost].second = std::max(old_bounds[it->x - leftmost].second, static_cast<int>(it->y));
}

int main()
{
    size_t n;

    std::cin >> n;

    std::vector<point> polygon(n);

    for (size_t i = 0; i < n; ++i)
    {
        std::cin >> polygon[i];
    }

    auto minmax_x = std::minmax_element(polygon.begin(), polygon.end(), [](const point& a, const point& b)
                                                                        {
                                                                            return (a.x < b.x);
                                                                        });

    int min_x = minmax_x.first->x;
    int max_x = minmax_x.second->x;

    auto tmp = std::pair<int, int>(std::numeric_limits<int>::max(), -std::numeric_limits<int>::max());

    auto result = std::vector<std::pair<int, int> >(max_x + 1 - min_x, tmp);

    for (size_t i = 0; i < n; ++i)
    {
        make_bounds(segment(polygon[i], polygon[(i + 1) % n]), result, min_x);
    }

    int count = 0;

    for (auto it = result.begin(); it < result.end(); ++it)
    {
        count += it->second - it->first + 1;
    }

    std::cout << count << "\n";

    for (int x = min_x; x <= max_x; ++x)
    {
        for (int y = result[x - min_x].first; y <= result[x - min_x].second; ++y)
        {
            std::cout << x << " " << y << "\n";
        }
    }
}